package com.lwc.cfdns.pojo.bo.system;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lwc.cfdns.pojo.bo.AbstractPageQuery;
import com.lwc.cfdns.pojo.entity.SystemGroup;
import com.lwc.cfdns.utils.StringUtils;
import lombok.Data;

/**
 * 组合数据搜索
 *
 * @author luwc
 * @title GroupBO
 * @description
 * @time 2023/7/12 15:00:11
 * @version: 1.0
 */
@Data
public class GroupBO extends AbstractPageQuery<SystemGroup> {
    private String status;
    private Long cateId;
    private String name;

    @Override
    public LambdaQueryWrapper<SystemGroup> toQueryWrapper() {
        LambdaQueryWrapper<SystemGroup> lambdaQueryWrapper = new LambdaQueryWrapper<>();

        if (StringUtils.isNotEmpty(getStatus())) {
            lambdaQueryWrapper.eq(SystemGroup::getStatus, getStatus());
        }
        if (StringUtils.isNotNull(getCateId())) {
            lambdaQueryWrapper.eq(SystemGroup::getCateId, getCateId());
        }
        if (StringUtils.isNotEmpty(getName())) {
            lambdaQueryWrapper.like(SystemGroup::getName, getName());
        }

        lambdaQueryWrapper.orderByDesc(SystemGroup::getId);
        return lambdaQueryWrapper;
    }
}
